package com.javafamily.familydemo.service;//package com.javafamily.familydemo.service;
//
//import com.javafamily.familydemo.model.Response;
//import org.apache.poi.hssf.usermodel.HSSFWorkbook;
//import org.apache.poi.ss.usermodel.Row;
//import org.apache.poi.ss.usermodel.Sheet;
//import org.apache.poi.ss.usermodel.Workbook;
//import org.springframework.http.HttpInputMessage;
//import org.springframework.http.HttpOutputMessage;
//import org.springframework.http.MediaType;
//import org.springframework.http.converter.AbstractHttpMessageConverter;
//import org.springframework.http.converter.HttpMessageNotReadableException;
//import org.springframework.http.converter.HttpMessageNotWritableException;
//import org.springframework.stereotype.Service;
//
//import java.io.IOException;
//
//@Service
//public class XlsConverter extends AbstractHttpMessageConverter<Response> {
//    private static final MediaType EXCEL_TYPE = MediaType.valueOf("application/vnd.ms-excel");
//
//    XlsConverter() {
//        super(EXCEL_TYPE);
//    }
//
//    @Override
//    protected boolean supports(Class<?> aClass) {
//        return (Response.class == aClass);
//    }
//
//    @Override
//    protected Response readInternal(Class<? extends Response> aClass, HttpInputMessage httpInputMessage) throws IOException, HttpMessageNotReadableException {
//        return null;
//    }
//
//    @Override
//    protected void writeInternal(final Response response, final HttpOutputMessage httpOutputMessage) throws IOException, HttpMessageNotWritableException {
//
//        final Workbook workbook = new HSSFWorkbook();
//        final Sheet sheet = workbook.createSheet();
//
//        final Row row = sheet.createRow(0);
//        row.createCell(0).setCellValue(response.getMessage());
//        row.createCell(1).setCellValue(response.getData().toString());
//
//        workbook.write(httpOutputMessage.getBody());
//
//    }
//}
